#ifndef LV_PORT_H
#define LV_PORT_H

#include "driver/i2c.h"
#include "esp_lcd_touch_cst816s.h"

// Using SPI2 in the example
#define LCD_HOST SPI2_HOST

#define CONFIG_LCD_COLOR_IN_PSRAM 1 /* use PSRAM as lvgl buff */

#if CONFIG_LCD_I80_COLOR_IN_PSRAM
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (80 * 1000 * 1000) /* use psram as lvgl buff */
#else
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (80 * 1000 * 1000) /* use sram as lvgl buff */
#endif

#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_SCLK 13
#define EXAMPLE_PIN_NUM_MOSI 21 /*SDA*/
#define EXAMPLE_PIN_NUM_MISO -1
#define EXAMPLE_PIN_NUM_LCD_DC 12
#define EXAMPLE_PIN_NUM_LCD_RST 11
#define EXAMPLE_PIN_NUM_LCD_CS 14
#define EXAMPLE_PIN_NUM_BK_LIGHT 10

// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 240
#define EXAMPLE_LCD_V_RES 240

#if CONFIG_LCD_COLOR_IN_PSRAM
#define LVGL_BUFF_SIZE (EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES/1.5) /* screen sized */
#else
#define LVGL_BUFF_SIZE (EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES / 5) /* 1/5 screen sized */
#endif

// Bit number used to represent command and parameter
#define EXAMPLE_LCD_CMD_BITS 8
#define EXAMPLE_LCD_PARAM_BITS 8

#define EXAMPLE_LVGL_TICK_PERIOD_MS 2

// Supported alignment: 16, 32, 64. A higher alignment can enables higher burst transfer size, thus a higher i80 bus throughput.
#define EXAMPLE_PSRAM_DATA_ALIGNMENT 64

#define CONFIG_EXAMPLE_LCD_TOUCH_ENABLED 1

#ifdef __cplusplus
extern "C"
{
#endif

    void lv_gui_task(void *arg);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
